﻿// Write methods to calculate minimum, maximum, average, sum and product of given set of integer numbers.
// Use variable number of arguments.

using System;

class FunctionsWithIntegersSet
{
    static void Main()
    {
        int min = Min(2, 5, 0, -6, int.MaxValue);
        Console.WriteLine("Minimum of the numbers set is: {0}", min);

        int max = Max(1, 2, 9, 0, -5, 22, 123, -123, 0);
        Console.WriteLine("Maximum of the numbers set is: {0}", max);

        decimal average = Average(0, 1, 10, 5, 5, 12, -3, 4, 444);
        Console.WriteLine("Average of the numbers set is: {0}", average);

        int sum = Sum(55, 45, 105, 0, -5);
        Console.WriteLine("Sum of the numbers set is: {0}", sum);

        int product = Product(60, 2, 3, 1);
        Console.WriteLine("Product of the numbers set is: {0}", product);
    }

    private static int Min(params int[] numbers)
    {
        int min = int.MaxValue;
        int length = numbers.Length;
        for (int i = 0; i < length; i++)
        {
            if (numbers[i] < min)
            {
                min = numbers[i];
            }
        }

        return min;
    }

    private static int Max(params int[] numbers)
    {
        int max = int.MinValue;
        int length = numbers.Length;
        for (int i = 0; i < length; i++)
        {
            if (numbers[i] > max)
            {
                max = numbers[i];
            }
        }

        return max;
    }

    private static decimal Average(params int[] numbers)
    {
        int sum = 0;
        int count = 0;
        foreach (int item in numbers)
        {
            if (item != 0)
            {
                sum += item;
            }
            count++;
        }
        decimal average = (decimal)sum / count;

        return average;
    }

    private static int Sum(params int[] numbers)
    {
        int sum = 0;
        foreach (int item in numbers)
        {
            if (item != 0)
            {
                sum += item;
            }
        }

        return sum;
    }

    private static int Product(params int[] numbers)
    {
        int product = 1;
        foreach (int item in numbers)
        {
            product *= item;
        }

        return product;
    }
}